/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package Admission;

import Academic.AcademicBean;
import Address.AddressBean;
import Category.CategoryBean;
import Country.CountryBean;
import Course.CourseBean;
import Facility.FacilityBean;
import Parents.ParentsBean;
import State.StateBean;
import Student.StudentBean;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Iterator;
import java.util.Vector;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 *
 * @author Mukesh
 */
public class StreamWiseReport extends HttpServlet {
   
  
    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        response.setContentType("text/html;charset=UTF-8");
        PrintWriter out = response.getWriter();
        try {
           int stream=0;
            if(request.getParameter("stream").length()!=0){
            stream=Integer.parseInt(request.getParameter("stream"));
            }
            Vector<Object> list;
            list = Admission.Query.viewAll(stream);
            if (!list.isEmpty()) {
                Iterator it = list.iterator();
                while (it.hasNext()) {
                    AdmissionBean ab = (AdmissionBean) it.next();
                    CourseBean cb = ab.getCourseBean();
                    StudentBean sb = ab.getStudentBean();
                    CategoryBean cab = ab.getCategoryBean();
                    AddressBean adb = sb.getAddressBean();
                    StateBean stb = adb.getStateBean();
                    CountryBean cob = stb.getCountryBean();
                    ParentsBean pb = ab.getParentsBean();
                    AddressBean adbp = pb.getAddressBean();
                    StateBean stbp = adbp.getStateBean();
                    CountryBean cobp = adbp.getCountryBean();
                    AcademicBean acb = ab.getAcademicBean();
                    FacilityBean fb = ab.getFacilityBean();

                    out.println("<tr id='" + ab.getAddmissionId() + "'>");
                    String gen = "";

                    out.println("<td>");
                    out.println("<b>Student Roll No.:</b>&nbsp" + ab.getRollNumber() + "<br><b>Admission Id:</b>&nbsp" + ab.getAddmissionId() + "<br><b>Email:</b>&nbsp" + ab.getStudentEmail() + "<br><b>Mobile No:</b>&nbsp" + ab.getStudentMobile() + "<br><b>Session:</b>&nbsp" + ab.getStudentSession() + "<br><b>Course:</b>&nbsp" + cb.getCourseName() + "<br><b>Stream:</b>&nbsp" + cb.getStream() + "<br><b>Semester:</b>&nbsp" + ab.getSemester() + "<br><b>Application No:</b>&nbsp" + ab.getApplicationNo() + "<br><b>Addmission Date:</b>&nbsp" + ab.getAdmissionDate());
                    out.println("</td>");
                    out.println("<td>");
                    out.println("<b>Student Name:</b>&nbsp" + sb.getStudentName() + "<br><b>Gender:</b>&nbsp" + sb.getGender() + "<br><b>Category:</b>&nbsp" + cab.getCategory() + "<br><b>Address1:</b>&nbsp" + adb.getAddress1() + "<br><b>Address2:</b>&nbsp" + adb.getAddress2() + "<br><b>Pin Code:</b>&nbsp" + adb.getPinCode());
                    out.println("</td>");
                    out.println("<td>");
                    out.println("<b>Father Name:</b>&nbsp" + pb.getFatherName() + "<br><b>Father Occupation:</b>&nbsp" + pb.getFatherOccupation() + "<br><b>Father Mobile:</b>&nbsp" + pb.getFatherMobileNo() + "<br><b>Mother Name:</b>&nbsp" + pb.getMotherName() + "<br><b>Mother Occupation:</b>&nbsp" + pb.getMotherOccupation() + "<br><b>Mother Mobile:</b>&nbsp" + pb.getMotherMobileNo() + "<br><b>Guardian Name:</b>&nbsp" + pb.getGuardianName() + "<br><b>Relation:</b>&nbsp" + pb.getRelation() + "<br><b>Guardian Occupation:</b>&nbsp" + pb.getGuardianOccupation() + "<br><b>Guardian Mobile:</b>&nbsp" + pb.getGuardianMobileNo());
                    out.println("</td>");
                    out.println("<td>");
                    out.println("<b>HS School/College Name:</b>&nbsp" + acb.getHighSchool() + "<br><b>HS. Board Name:</b>&nbsp" + acb.getHighBoardName() + "<br><b>HS. Obtain Marks:</b>&nbsp" + acb.getHighMarksObtained() + "<br><b>HS. Maximum Marks:</b>&nbsp" + acb.getHighMaxMarks() + "<br><b>IM. School/College Name:</b>&nbsp" + acb.getInterSchool() + "<br><b>IM. Board Name:</b>&nbsp" + acb.getInterBoardName() + "<br><b>IM. Obtain Marks:</b>&nbsp" + acb.getInterMarksObtained() + "<br><b>IM. Maximum Marks:</b>&nbsp" + acb.getInterMaxMarks() + "<br><b>Other School/College Name:</b>&nbsp" + acb.getOther() + "<br><b>Other Board Name:</b>&nbsp" + acb.getOtherBoardName() + "<br><b>Other Obtain Marks:</b>&nbsp" + acb.getOhterMarksObtained() + "<br><b>Other Maximum Marks:</b>&nbsp" + acb.getOtherMaxMarks());
                    out.println("</td>");
                    out.println("<td>");
                    String trans;
                    String hostel;
                    String mess;
                    if (fb.getTransportationStatus() == 1) {
                        trans = "Yes";
                    } else {
                        trans = "No";
                    }
                    if (fb.getHostelStatus() == 1) {
                        hostel = "Yes";
                    } else {
                        hostel = "No";
                    }
                    if (fb.getMessStatus() == 1) {
                        mess = "Yes";
                    } else {
                        mess = "No";
                    }
                    String appdate = ab.getAdmissionDate().toString();
                    String appd[] = appdate.split("-");
                    String aapdate = Integer.parseInt(appd[1]) + "/" + Integer.parseInt(appd[2]) + "/" + Integer.parseInt(appd[0]);

                    out.println("<b>Transport Status:</b>&nbsp" + trans + "<br><br/><br><b>Hostel Status:</b>&nbsp" + hostel + "<br><br/><br><b>Mess Status:</b>&nbsp" + mess);
                    out.println("</td>");

                    out.println("</tr>");
                }
            } else {
                out.println("<tr>");
                out.println("<td colspan='3'>");
                out.println("<b>No Record Found</b>");
                out.println("</td>");
                out.println("</tr>");
            }
            }catch(Exception e){
            
            } finally {
            out.close();
        }
    } 

    // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
    
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        processRequest(request, response);
    } 

    
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        processRequest(request, response);
    }

    
    @Override
    public String getServletInfo() {
        return "Short description";
    }// </editor-fold>

}
